//
//  OSearch.m
//  soccer
//
//  Created by Alan on 15/9/19.
//  Copyright (c) 2015年 上官千城. All rights reserved.
//

#import "OSearch.h"

@implementation OSearch

/*
-(instancetype) initWithCallBack:(SEL)callBack
{
    return [super initWithName:@"OSearchFriend" callBack:callBack];
}*/

-(instancetype) initWithCallBack:(SEL)callBack for:(NSObject *)recvObjc
{
    return [super initWithName:@"OSearchFriend" recvObjc:recvObjc callBack:callBack];
}

-(void) request
{
    NSDictionary* params = @{
        @"fAccount":self.fAccount
    };
    
    [self send:params];
}

-(void) run:(NSData *)data erc:(NSInteger)erc
{
    if (erc != SUCC) {
        //TODO:fail logic process;
        NSString *str = [NSString stringWithFormat:@"登录失败erc= %ld",erc];
        UIAlertView *failAlert = [[UIAlertView alloc] initWithTitle:@"提示" message:str delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
        [failAlert show];
        return;
    }
    
    NSDictionary* dic = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:nil];
    
    NSLog(@"reg succ data=%@",dic);
    self.userId = [dic objectForKey:@"userId"];
    self.nickName = [dic objectForKey:@"nickName"];
    //TODO:succ logic process;
    /* if (muDelegate) {
     muDelegate(self);
     }*/
    [self mu];
}


@end
